package com.hospital.medicals.controller;

import com.hospital.medicals.entity.MedicalUser;
import com.hospital.medicals.service.MedicalUserService;
import com.util.ResultUtils;
import com.util.ResultVo;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/hospital/medicals")
public class MedicalUserController {
    @Autowired
    private MedicalUserService medicalUserService;

    /**
     * 获取医务人员信息列表
     * @return
     */

    // 1 查询所有用户信息
    @RequestMapping("/getAllMedicals")
    @ApiOperation(value = "查询医务人员信息")
    public ResultVo getAllMedicals() {
        List<MedicalUser> doctorList = medicalUserService.list();
        if (doctorList.size() > 0) {
            return ResultUtils.success("正确获得医务人员信息", doctorList);
        } else {
            return ResultUtils.error("不能正确获取医务人员信息");
        }
    }

    // 2 修改用户信息
    @RequestMapping("/updateMedicalsById")
    @ApiOperation(value = "修改医务人员信息")
    public void updateMedicalsById(MedicalUser doctor) {
        medicalUserService.updateMedicals(doctor);
    }

    // 3 删除用户信息
    @RequestMapping("/deleteMedicalsById/{id}")
    @ApiOperation(value = "删除医务人员信息")
    public void deleteMedicalsById(@PathVariable Integer id) {
        medicalUserService.deleteMedicals(id);
    }

}

